﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;

namespace DAO
{
    public class PhuThuDAO
    {
        public static DataTable GetAll()
        {
            DataProvider dp = new DataProvider();
            string sql = "Select * From PhuThu";
            DataTable dt = dp.ExecuteQuery(sql);
            return dt;
        }

        public static DataTable LayTyLePhuThu(int sothutu)
        {
            DataProvider dp = new DataProvider();
            string sql = "Select * From PhuThu Where SoThuTu = " + sothutu + "";
            DataTable dt = dp.ExecuteQuery(sql);
            return dt;
        }

        public static void ThemTyLePhuThu(PhuThuDTO pt)
        {
            string sql = string.Format("INSERT INTO PhuThu(MaPhuThu, SoThuTu, TyLePhuThu) VALUES (" + pt.MaPhuThu + "," + pt.SoThuTu + "," + pt.TyLePhuThu + ")");
            DataProvider.ExecuteNonQuery(sql);
        }

        public static void CapNhatTyLePhuThu(PhuThuDTO pt)
        {
            string sql = string.Format("Update PhuThu Set SoThuTu = " + pt.SoThuTu + ", TyLePhuThu = " + pt.TyLePhuThu + " Where MaPhuThu = " + pt.MaPhuThu + "");
            DataProvider.ExecuteNonQuery(sql);
        }

        public static void XoaTyLePhuThu(int maphuthu)
        {
            string sql = string.Format("Delete From PhuThu Where MaPhuThu = " + maphuthu + "");
            DataProvider.ExecuteNonQuery(sql);
        }
    }
}
